using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using MULENetworking;


namespace MULEServer
{
    public class Production
    {
        public Production()
        {

        }

        public int produceEnergy(IPlayer player)
        {
            int unitsProduced = 0;
            ArrayList listOfSquares = new ArrayList();
            IMapSquare tempSquare;
            for (int i = 0; i < player.plotsOwned.Count; i++)
            {
                tempSquare = (IMapSquare)player.plotsOwned[i];
                if (tempSquare.Mule == "energy")
                {
                    listOfSquares.Add(tempSquare);
                }
            }
            for (int i = 0; i < listOfSquares.Count; i++)
            {
                tempSquare = (IMapSquare)listOfSquares[i];
                if (tempSquare.Type == "energy")
                {
                    unitsProduced += 3;
                }
                if (tempSquare.Type == "food")
                {
                    unitsProduced += 2;
                }
                if (tempSquare.Type == "smithore")
                {
                    unitsProduced += 1;
                }
            }
            unitsProduced += listOfSquares.Count - 1;
            return unitsProduced;
        }

        public int produceSmithore(IPlayer player)
        {
            int unitsProduced = 0;
            ArrayList listOfSquares = new ArrayList();
            IMapSquare tempSquare;
            for (int i = 0; i < player.plotsOwned.Count; i++)
            {
                tempSquare = (IMapSquare)player.plotsOwned[i];
                if (tempSquare.Mule == "smithore")
                {
                    listOfSquares.Add(tempSquare);
                }
            }
            for (int i = 0; i < listOfSquares.Count; i++)
            {
                tempSquare = (IMapSquare)listOfSquares[i];
                if (tempSquare.Type == "energy")
                {
                    unitsProduced += 1;
                }
                if (tempSquare.Type == "food")
                {
                    unitsProduced += 0;
                }
                if (tempSquare.Type == "smithore")
                {
                    if (tempSquare.NumMountains == 1)
                    {
                        unitsProduced += 2;
                    }
                    if (tempSquare.NumMountains == 2)
                    {
                        unitsProduced += 3;
                    }
                    if (tempSquare.NumMountains == 3)
                    {
                        unitsProduced += 4;
                    }
                }
            }
            unitsProduced += listOfSquares.Count - 1;
            return unitsProduced;
        }

        public int produceFood(IPlayer player)
        {
            int unitsProduced = 0;
            ArrayList listOfSquares = new ArrayList();
            IMapSquare tempSquare;
            for (int i = 0; i < player.plotsOwned.Count; i++)
            {
                tempSquare = (IMapSquare)player.plotsOwned[i];
                if (tempSquare.Mule == "food")
                {
                    listOfSquares.Add(tempSquare);
                }
            }
            for (int i = 0; i < listOfSquares.Count; i++)
            {
                tempSquare = (IMapSquare)listOfSquares[i];
                if (tempSquare.Type == "energy")
                {
                    unitsProduced += 2;
                }
                if (tempSquare.Type == "food")
                {
                    unitsProduced += 4;
                }
                if (tempSquare.Type == "smithore")
                {
                    unitsProduced += 1;
                }
            }
            unitsProduced += listOfSquares.Count - 1;
            return unitsProduced;
        }
    }
}
